<template>
  <div
    class="session-list-items"
    :class="{ 'session-list-items-after': afterStyle }"
    @click="addStyle"
  >
    <div class="session-list-items-head">
      <img :src="mydata.avastar" alt="" />
    </div>
    <div
      class="session-list-items-item"
      :class="{ 'session-list-items-item-after': afterStyle }"
    >
      <span class="session-list-items-item-title">{{ mydata.name }}</span>
      <span class="session-list-items-item-time">{{ mydata.time }}</span>
      <span class="session-list-items-item-brief">{{ mydata.content }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: ["mydata", "clickStyle", "idx"],
  created() {
    this.afterStyle = this.clickStyle;
  },
  data() {
    return {
      afterStyle: false,
      index: this.idx,
    };
  },
  methods: {
    addStyle() {
      console.log("click me!");
      this.$emit("clearStyle", this.index);
    },
  },
};
</script>

<style>
.session-list-items {
  height: 64px;
  width: 300px;
  display: flex;
  border-bottom: 1px solid rgb(242, 242, 242);
}

.session-list-items-after {
  background-color: #006eff19;
}

.session-list-items-item-after {
  border-right-style: solid;
  border-right-width: 4px;
  border-right-color: dodgerblue;
}

.session-list-items-head {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: grey;
  margin: 17px;
}

.session-list-items-head img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.session-list-items-item {
  width: 246px;
  height: 64px;
  line-height: 48px;
}

.session-list-items-item .session-list-items-item-title {
  display: block;
  height: 22px;
  font-size: 14px;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  font-weight: 400;
  font-style: normal;
  text-align: left;
}

.session-list-items-item .session-list-items-item-time {
  float: right;
  color: #cccccc;
  font-size: 12px;
  position: relative;
  top: -25px;
  left: -25px;
}

.session-list-items-item .session-list-items-item-brief {
  display: block;
  font-size: 12px;
  color: #999999;
  width: 160px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-family: PingFangSC-Regular, "PingFang SC", sans-serif;
  font-weight: 400;
  font-style: normal;
  text-align: left;
}
</style>